package com.example.demo.mapper;

import com.example.demo.entity.Relics;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface RelicsMapper {

    // 模糊搜索文物（按名称,种类或者朝代）
    @Select("SELECT * FROM relics WHERE " +
            "name LIKE CONCAT('%', #{keyword}, '%') OR " +
            "category LIKE CONCAT('%', #{keyword}, '%') OR " +
            "dynasty LIKE CONCAT('%', #{keyword}, '%') OR "  +
            "location LIKE CONCAT('%', #{keyword}, '%') "
    )
    List<Relics> searchRelics(@Param("keyword") String keyword);

    // 获取所有文物列表
    @Select("SELECT * FROM relics")
    List<Relics> getAllRelics();

    // 获取文物详情
    @Select("SELECT * FROM relics WHERE id = #{id}")
    Relics getRelicDetail(@Param("id") int id);

}
